package com.lds.register.center.server.business.appinstance.controller;

import com.lds.management.center.common.model.dto.ResultDTO;
import com.lds.register.center.client.common.model.request.HeartbeatRequest;
import com.lds.register.center.client.common.model.request.RegisterAppInstanceRequest;
import com.lds.register.center.client.common.model.response.RegisterAppInstanceResponse;
import com.lds.register.center.server.business.appinstance.service.AppInstanceRemoteService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/remote/app_instance")
public class AppInstanceRemoteController {
    private final AppInstanceRemoteService appInstanceRemoteService;

    @RequestMapping("/register")
    public ResultDTO<RegisterAppInstanceResponse> registerAppInstance(@RequestBody @Validated RegisterAppInstanceRequest request) {
        return appInstanceRemoteService.registerAppInstance(request);
    }

    @RequestMapping("/heartbeat")
    public ResultDTO<Boolean> heartbeat(@RequestBody @Validated HeartbeatRequest request) {
        return appInstanceRemoteService.heartbeat(request);
    }
}
